'use strict';

const Service = require('egg').Service;

class SuanmingService extends Service {
  async suanming(res) {
    let sendMsg = this.ctx.service.sendMsg;
    let id = res.user_id;
    let result = await this.ctx.curl(`https://api.fanlisky.cn/api/qr-fortune/get/${id}`);
    result = JSON.parse(result.data.toString());
    sendMsg.sendToGroup({
      id: res.group_id,
      msg: `[CQ:at,qq=${res.user_id}]\n今日运势：\n${result.data.fortuneSummary}\n${result.data.luckyStar}\n\n${result.data.signText}\n\n${result.data.unSignText}`
    })
  }
}

module.exports = SuanmingService;
